package cn.legend.travel.guide.controller;

import cn.legend.travel.common.web.JsonResult;
import cn.legend.travel.guide.pojo.entity.User;
import cn.legend.travel.guide.service.IGuideService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/guide")
@Api(tags = "攻略模块")
public class GuideController {

    @Autowired
    IGuideService guideService;

    @GetMapping("/list/{page}")
    @ApiOperation("攻略列表功能")
    public JsonResult listForGeneral(@PathVariable String page) {

        return JsonResult.ok(guideService.getGuideList(Integer.parseInt(page)));
    }

    @GetMapping("/detail/{guideId}")
    @ApiOperation("攻略详情功能")
    public JsonResult getGuideDetail(@PathVariable Long guideId) {
        return JsonResult.ok(guideService.getGuideDetailById(guideId));
    }

    @GetMapping("/detail/comment")
    @ApiOperation("攻略评论详情功能")
    public JsonResult getGuideCommentDetail(@RequestParam(value = "pageNum") Integer pageNum, @RequestParam(value = "guideId") String guideId){

        return JsonResult.ok(guideService.getGuideDetailCommentByGuideId(pageNum,Long.parseLong(guideId)));

    }

}
